#pragma once

enum LOCATION_FORMAT
{
	FMT_HTML,
	FMT_XHTML, // '&amp;' instead of '&'
	FMT_PLAIN_TEXT,
	FMT_TEXT_ONLY,
	FMT_URL_ONLY,
};

class CMagicScannerClient
{
	std::string m_strUserFriendly;
	std::string m_strLat;
	std::string m_strLng;
	std::string m_strLastModified;
	std::string m_strLang;

	std::string m_strSessionKey;
	std::string m_strUserName;
	std::string m_strPasswordHash;
	std::string m_strLastError;

	std::string FormatLocation
		( IN LOCATION_FORMAT fmt
		, IN const std::string& strReferrer
		);

public:

	std::string GetLastError() const
	{
		return m_strLastError;
	}

	std::string GetLocationText
		( IN const std::string& strApiKey
		, IN const std::string& strReferrer
		)
	{
		return GetLocation(FMT_PLAIN_TEXT, strApiKey, strReferrer);
	}

	std::string GetLocationHtml
		( IN const std::string& strApiKey
		, IN const std::string& strReferrer
		)
	{
		return GetLocation(FMT_XHTML, strApiKey, strReferrer);
	}

	std::string GetLocation
		( IN LOCATION_FORMAT fmt
		, IN const std::string& strApiKey
		, IN const std::string& strReferrer
		);

	int Login
		( IN const std::string& strUserName
		, IN const std::string& strPasswordHash
		);

	void SetLang
		( IN const std::string& strUserLang
		)
	{
		m_strLang = strUserLang;
	}
};

// Utility functions
//
std::string
MD5Hash
	( IN const std::string& text
	);
